package com.atguigu.jdk;

import java.util.Calendar;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description: jdk源码分析：工厂模式
 * @create: 2022-01-23 16:25
 **/
public class Factory {
    public static void main(String[] args) {
        //1.简单工厂模式(根据传的类型不同，创建不同的类) getInstance 是 Calendar 静态方法
        Calendar cal = Calendar.getInstance();
        // 注意月份下标从0开始，所以取月份要+1
        System.out.println("年:" + cal.get(Calendar.YEAR));
        System.out.println("月:" + (cal.get(Calendar.MONTH) + 1));
        System.out.println("日:" + cal.get(Calendar.DAY_OF_MONTH));
        System.out.println("时:" + cal.get(Calendar.HOUR_OF_DAY));
        System.out.println("分:" + cal.get(Calendar.MINUTE));
        System.out.println("秒:" + cal.get(Calendar.SECOND));
    }
}
